package com.nekonomics

import api.HttpApp
import domain.service.UserService
import schedule.TradeScheduler

import zio.http.Server
import zio.logging.backend.SLF4J
import zio.{Runtime, Scope, ZIO, ZIOAppArgs, ZIOAppDefault, ZLayer}

object Main extends ZIOAppDefault {

  override val bootstrap: ZLayer[ZIOAppArgs, Any, Any] =
    Runtime.removeDefaultLoggers >>> SLF4J.slf4j


  def run = {
    for {
      _ <- TradeScheduler.launch
      _ <- Server.serve(HttpApp.routes)
    } yield ()
  }.provide(
    Server.defaultWithPort(9000),
    domain.service.layers
  )

}
